package com.bigger.arch.app.web.aop.test;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class SoaClientInvokeAop {

    @Pointcut("execution(public * *..*Client.*(*..*RequestType,..)) && bean(*Client)")
    public void execute() {
        //System.out.println("执行中...");
    }

    @Around("execute()")
    public Object around(ProceedingJoinPoint joinPoint) {
        String title = joinPoint.getTarget().getClass().getName() + "." + joinPoint.getSignature().getName();
        try {
            System.out.println(title + " 执行开始...");
            return joinPoint.proceed();
        } catch (Throwable throwable) {
            System.out.println(title + " 执行异常...");
            throwable.printStackTrace();
            return null;
        } finally {
            System.out.println(title + " 执行结束...");
        }
    }
}
